package com.yanqu.road.dataHelper.action;

import com.yanqu.road.dataHelper.action.excel.TwinsUnionRank;
import com.yanqu.road.dataHelper.gameServer.GameServer;
import com.yanqu.road.dataHelper.manager.DataMgr;
import com.yanqu.road.dataHelper.manager.ServerMgr;
import com.yanqu.road.entity.servercenter.ServerInfo;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class TwinsUnionRankExcel extends actionBase{
    public void go(List<Long> serverList){
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        List<Future> futureList = new ArrayList<>();
        String activityIdStr = "9330171,9330172,9330173,9330174,9330175,9330176,9330177,9330178,9330179,9330180,9330181,9330182,9330183,9330184,9330185,9330186,9330187,9330188,9330189,930190,9330191,9330192,9330193,9330194,9330195,9330196,9330197,9330198,9330199,9330200,9330201,9330202,9330203,9330204,9330205,9330206,9330207,9330208,933029,9330210,9330211,9330212,9330213,9330214,9330215,9330216,9330217,9330218,9330219,9330220,9330412,9330413,9330414,9330415,9330461,9330462,9330463";
        activityIdStr = "9034168";
        List<Integer> activityIdList = StringUtils.stringToIntegerList(activityIdStr,",");
        for(int activityId : activityIdList){
            for(Long serverId : serverList){
                if(ServerMgr.getServerInfoList().containsKey(serverId)){
                    ServerInfo serverInfo = ServerMgr.getServerInfoList().get(serverId);
                    Future future = executorService.submit(new Callable<Boolean>() {
                        @Override
                        public Boolean call() throws Exception {
                            GameServer testGameServer = new GameServer(serverInfo);
                            TwinsUnionRank aaa = new TwinsUnionRank(testGameServer);
                            aaa.go1(activityId);
                            return true;
                        }
                    });
                    futureList.add(future);
                }
            }
            isResult(futureList);
        }
        DataMgr.makeExcelData2Txt("");
        DataMgr.outText("11月18日-11月20日邮件");
    }
}
